﻿using System;
using System.Linq;

using Bootstrap5.Abstractions;

using Microsoft.AspNetCore.Components;

namespace Bootstrap5;

partial class NavBar
{

    [Parameter] [CssClass("bg-")] public BgColor BgColor { get; set; } = BgColor.Primary;
    [Parameter] public BreakPoint ExpandBreakPoint { get; set; } = BreakPoint.LG;
    [Parameter] public RenderFragment BrandContent { get; set; }
    [Parameter] [CssClass("fixed-")] public UpDownPlacement? Fixed { get; set; }
    [Parameter] [CssClass("sticky-")] public UpDownPlacement? Sticky { get; set; }
    [Parameter] public bool Fluid { get; set; }

    protected override void CreateCssClass(ICssClassBuilder builder)
    {
        builder.Add("navbar")
        .Add($"navbar-expand-{ExpandBreakPoint.GetEnumCssClass()}")
    .Add(string.Format("navbar-{0}", GetNavBarBg()));
    }

    string GetNavBarBg()
    {
        if (new[] { BgColor.Light, BgColor.Body, BgColor.Warning }.Contains(BgColor))
        {
            return "light";
        }
        return "dark";
    }
}
